from django.contrib.auth.models import Permission, Group
from django.contrib.contenttypes.models import ContentType
from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet

from apps.meiduo_admin.paginations import MyPage
from apps.meiduo_admin.serializers.perm_serialziers import PermModelSerializer, PermContentTypeSerializer, \
    GroupModelSerializer, GroupPermSimpleSerializer


class GroupPermView(ListAPIView):
    queryset = Permission.objects.all()
    serializer_class = GroupPermSimpleSerializer

class GroupView(ModelViewSet):
    queryset = Group.objects.all()
    serializer_class = GroupModelSerializer
    pagination_class = MyPage

class PermContentTypeView(ListAPIView):
    queryset = ContentType.objects.all()
    serializer_class = PermContentTypeSerializer

class PermView(ModelViewSet):
    queryset = Permission.objects.all()
    serializer_class = PermModelSerializer
    pagination_class  = MyPage